package com.tyk.bookstore.back.system.valid.annotation;

import com.tyk.bookstore.back.system.valid.type.MenuFieldValidType;
import com.tyk.bookstore.back.system.valid.validator.MenuFieldConstraintValidator;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * @author tyk
 * @description 校验菜单字段（不校验NULL值）
 */
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Repeatable(MenuFieldValid.List.class)
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = MenuFieldConstraintValidator.class)
public @interface MenuFieldValid {
    MenuFieldValidType[] value();

    String message() default "菜单字段不合法";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
    @Retention(RUNTIME)
    @Documented
    @interface List {
        MenuFieldValid[] value();
    }
}
